#ifndef _AUTOMATA2_H_
#define	_AUTOMATA2_H_

#define BUF_SIZE 255

#include <stdio.h>
#include "longInt.h"

/******************************************************************************/
/**                              Data Structures                             **/
/******************************************************************************/


typedef struct t_input{
    int dim;
    char ** chains;
}t_input;

typedef struct t_int_vector{
    int dim;
    int * vec;
    int maxDim;
}t_int_vector;

typedef struct t_matrix{
    int dimFils;
    int fils;
    int cols;
    int ** data; 
}t_matrix;

typedef struct t_table{
    char * alphabet; //null terminated string, where each char is an alphabet's symbol
    int originalDim; //How many states where declared at first, from the file
    t_int_vector states;
    int iniState;
    t_int_vector finalStates;
        t_matrix transitions;
    t_input input;
    int originalFinalDim; //How many states where declared as final, at first
}t_table;


/******************************************************************************/
/**                              Prototypes                                  **/
/******************************************************************************/

t_matrix buildMatrix(int fil, int col);
t_table parseFile(FILE * f);
int getSymIndex(char * alphabet, char symbol);
int getStateIndex(t_table * t, int state);
int isSelfContained(int origDim, int oldSt, int newSt);
void addTransition(t_table * t, int from_state, int symbol_index, int to_state);
int getline(char * line, int max, FILE * f);
void removeLambdaTrans(t_table * t);
//void recurseLambda(int state, t_table * t);
int composeStates(int originalDim, int receiver, int giver);
void setLambdaClosure(int state, t_table * t, int * cl);
void markAsSeen(int state);
void writeFile(FILE * f, t_table * t);

//int isFinal(t_table *t, int state);

#endif
